package com.mfw.springboot.model.vo;

import com.mfw.springboot.model.entity.TrainingRule;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 训练规则视图
 *
 * @author mfw
 * @from <a href="https://gitee.com/hanhuaifei/projects">我的gitee</a>
 * @Date 2024/9/26
 */
@Data
public class TrainingRuleVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 规则名称
     */
    private String ruleName;

    /**
     * 规则描述
     */
    private String description;

    /**
     * 训练内容详情
     */
    private String content;

    /**
     * 训练次数
     */
    private Integer num;

    /**
     * 开始时间
     */
    private Date startTime;

    /**
     * 结束时间
     */
    private Date endTime;

    /**
     * 创建教练ID
     */
    private Long userId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    private static final long serialVersionUID = 1L;


    /**
     * 创建用户信息
     */
    private UserVO user;

    /**
     * 封装类转对象
     *
     * @param trainingRuleVO
     * @return
     */
    public static TrainingRule voToObj(TrainingRuleVO trainingRuleVO) {
        if (trainingRuleVO == null) {
            return null;
        }
        TrainingRule trainingRule = new TrainingRule();
        BeanUtils.copyProperties(trainingRuleVO, trainingRule);
        return trainingRule;
    }

    /**
     * 对象转封装类
     *
     * @param trainingRule
     * @return
     */
    public static TrainingRuleVO objToVo(TrainingRule trainingRule) {
        if (trainingRule == null) {
            return null;
        }
        TrainingRuleVO trainingRuleVO = new TrainingRuleVO();
        BeanUtils.copyProperties(trainingRule, trainingRuleVO);
        return trainingRuleVO;
    }
}
